package pdf;

import javax.imageio.stream.FileImageOutputStream;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;

/**
 * @author khaiLoon
 * @date 2018/11/21
 **/
public class Tostr {
    public static void main(String[] args) {
        byte2image();
    }

    /**
     * 生成pdf
     */
    public   static  void byte2image( ){
        try{

            byte[] bytes = Files.readAllBytes(Paths.get("/work/public/bold/early/src/main/java/pdf", "pdf.text"));
            byte[] abc = Base64.getDecoder().decode(bytes);
            FileImageOutputStream imageOutput =
                    new FileImageOutputStream(new File("/work/public/bold/early/src/main/java/pdf/xxx.pdf"));
            imageOutput.write(abc, 0, abc.length);
            imageOutput.close();
        } catch(Exception ex) {
            System.out.println("Exception: " + ex);
            ex.printStackTrace();
        }
    }

}
